package s3

import (
	"encoding/xml"
	"io"
	"io/ioutil"
)

const (
	UploadIdSplit = "::"
)

// InitiateMultipartUploadResult s3协议中分片上传，创建分片返回的结果
type InitiateMultipartUploadResult struct {
	XMLName  xml.Name `xml:"InitiateMultipartUploadResult"`
	Bucket   string   `xml:"Bucket"`
	Key      string   `xml:"Key"`
	UploadId string   `xml:"UploadId"`
}

func (part *InitiateMultipartUploadResult) Unmarshal(r io.Reader) (err error) {
	var data []byte
	if data, err = ioutil.ReadAll(r); err != nil {
		return err
	}
	return xml.Unmarshal(data, part)
}

func (part *InitiateMultipartUploadResult) Marshal() (data []byte, err error) {
	data, err = xml.Marshal(part)
	return
}
